<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
            "maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>挂起申请</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/rams.css"/>
    <style>
    .aui-bar-nav{
        background-color: #e10010;
    }
    .aui-icon-left{
        font-size: 0.7rem;
        font-weight: 700;
    }

    </style>
</head>
<body >
<div class="bodyContainer bodyPosition">
    <header class="aui-bar aui-bar-nav headerMarginTop">
        <div class="aui-pull-left aui-btn">
            <span class="aui-iconfont aui-icon-left"></span><span class="aui-Font" onclick="api.closeWin()">返回</span>
        </div>
        <div class="aui-title">挂起申请</div>
        <div class="aui-pull-right header_confirm">
            <span class="aui_Font" onclick="save()">确定</span>
        </div>
    </header>
    <div>
        <div id="workSheet_area" class="aui-padded-l-15">
            <!--挂起类型-->
            <div class="workSheet_Choose_div">
                <div  class="workSheet_Choose_div_sp">
                    <div class="inline-block" style="width: 30%;">
                        <span class="redStar">*</span>
                        挂起类型：
                    </div>
                    <div class="inline-block" style="width: 50%;">
                        <select id="disposeWay">
                            <option value='' disabled selected style='display:none;'>请选择</option>
                        </select>
                    </div>
                    <div  class="inline-block lianTong-icon-down" >
                        <span class="aui-iconfont aui-icon-down rams-float-right" ></span>
                    </div>
                </div>
                <div class="greyLine96"></div>
            </div>
            <!--挂起原因-->
            <div class="infoMarginTop">
                <div>
                    <span class="whiteStar">*</span>
                    挂起原因：
                </div>
                <div>
                    <textarea  placeholder="请输入" id="remark"></textarea>
                </div>
            </div>
        </div>
    </div>
</div>
<script id="type-selector" type="text/template">
    <option value=""  disabled selected >请选择</option>
    {{ for(var i=0;i<it.nameList.length;i++){
        if(!common.isEmpty(it.nameList[i])){
    }}
    <option value="{{=it.idList[i]}}">{{=it.nameList[i]}}</option>
    {{
        }
    }
    }}
</script>
<script>
    apiready = function() {
        initSelect();
    }
    //动态加载select
    function initSelect(){
        common.post({
            url : config.getAllIdUrl,
            isLoading:false,
            data:{
                parentdictid:parentdictid.suspendApplication,
            },
            success : function(ret){
                if(ret&&ret.status==='200'){
                   //填写信息
                   if (ret.data&&ret.data.name&&ret.data.id&&ret.data.name.length > 0) {
                       var data = ret.data;
                       var strName = (data.name).split(",");    //字符分割;
                       var strId  = (data.id).split(",");    //字符分割;
                       var params = {
                           idList:[],
                           nameList:[]
                       }
                       params.idList = strId
                       params.nameList = strName
                       $api.html($api.byId('disposeWay'), "");
                       var disposeWay = doT.template($api.text($api.byId('type-selector')));
                       $api.html($api.byId('disposeWay'), disposeWay(params));
                   }else {
                       api.alert({
                           msg:'没有可用的挂起类型！'
                       })
                   }
               }else{
                   api.toast({
                       msg: '获取挂起类型失败！',
                       duration: config.duration,
                       location: 'middle'
                   });
                }
            }
        });
    }
    function save() {
        var disposeWay = $("#disposeWay option:selected").val();    //挂起类型
        var remark = $api.trim($api.val($api.byId('remark')));       //挂起原因
        var wsNum = $api.getStorage(storageKey.wsNum);               //工单号
        var processId = $api.getStorage(storageKey.processId);       //流程id
        var imgID = "";                                             //图片信息,接口需要传值，但是页面上没有此录入项
        if(common.isEmpty(disposeWay)){
            api.toast({
                msg: '请选择挂起类型！',
                duration: config.duration,
                location: 'middle'
            });
            return;
        }
        api.confirm({
            title: '挂起审核',
            msg: '是否提交？',
            buttons: ['确定', '取消']
        }, function(retBtn, err) {
            if(retBtn.buttonIndex===1){
                common.post({
                    url:config.suspendApplicationUrl,
                    isLoading: true,
                    text: "提交中...",
                    data:{
                        wsNum: wsNum,
                        processId: processId,
                        remark: remark,
                        imgID: imgID,
                        dispose_way: disposeWay
                    },
                    success: function (ret) {
                        if (ret.status==='200'){
                            api.alert({
                                title: '提示',
                                msg: '挂起申请操作成功！',
                            }, function (ret, err) {
                                common.closeAndReloadAppointPage('process_success_reload_worksheet_detail');
                            });
                        } else {
                            // 因为返回的错误信息是英文，所有没有单独显示错误信息。
                            api.toast({
                                msg:  '挂起申请操作失败！',
                                duration: config.duration,
                                location: 'middle'
                            });
                        }

                    }
                });
            }
        });
    }
</script>
<script type="text/javascript" src="../../script/malfunction/jquery-3.2.1.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
</body>
</html>
